package com.hqyj.controller.TraderAndStorage;


import com.hqyj.pojo.Goods;
import com.hqyj.pojo.ResponseResult;
import com.hqyj.pojo.ResultVo;
import com.hqyj.pojo.ResultVoH;
import com.hqyj.service.IGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author rock
 * @since 2022-10-03
 */
@RestController
@RequestMapping("/user")
public class GoodsController {

    @Autowired
    private IGoodsService goodsService;
    //点击入库
    @GetMapping("/goodsAdd")
    public ResultVoH goodsAdd(Goods goods) {
        return goodsService.goodsAdd(goods);
    }
    //入库提交
    @GetMapping("/add")
    public ResultVoH add(Goods goods) {
        return goodsService.add(goods);
    }


    @GetMapping("/list")
    public ResultVoH goodsList(Goods goods){
        return goodsService.goodsList(goods);
    }

    @GetMapping("/change")
    public ResultVoH goodsChange(Goods goods){
        return goodsService.goodsChange(goods);
    }

    @GetMapping("/goods")
    public ResultVoH queryGoodsByStorageType(String storageType){
        return goodsService.queryAllByStorageType(storageType);
    }


    /**
     * 分页查询所有数据
     *
     * @return 所有数据
     */
    @GetMapping("/sgoods")
    public ResponseResult selectAll(Integer current, Integer size, String type, String suppliersName) {

        return goodsService.findAll(current,size, type,suppliersName);
    }

    /**
     * 查询所有商品的分类
     * @return
     */
    @GetMapping("/types")
    public ResponseResult selectType(){
        return goodsService.getType();
    }

    /**
     * 查询所有的供货商
     * @return
     */
    @GetMapping("/goodsSuppliers")
    public ResponseResult selectSupplisers(){
        return goodsService.getSuppliers();
    }

    /**
     *修改商品信息
     * @param goods
     * @return
     */
    @PostMapping("/goods/insert")
    public ResponseResult insertGoods(@RequestBody Goods goods){
        return goodsService.insertGoods(goods);
    }
}

